<template>
  <div v-loading="$store.state.pageLoading" class="app-container dashboard-editor-container" element-loading-text="数据加载中...">
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane v-for="(item, index) in  $store.state.aggregateDataList" :lazy="true" :label="item" :name="index + ''" :key="index">
        <div style="padding:0 30px 30px">
          <el-row type="flex" justify="space-between">
            <el-col>
              <p>全部到场人数：{{ $store.state.aggregateDataInfo.dcnum || 0 }}人</p>
            </el-col>
            <el-col>
              <p style="text-align:center">半小时内入场人数: {{ $store.state.aggregateDataInfo.hfnum || 0 }}人</p>
            </el-col>
            <el-col>
              <p style="text-align:right">半小时内出场人数: {{ $store.state.aggregateDataInfo.hfoutnum || 0 }}人</p>
            </el-col>
          </el-row>
          <el-row type="flex" justify="space-between">
            <el-col>
              <p>嘉宾到场率：{{ $store.state.aggregateDataInfo.zdcrate*100+'%' || 0 }}</p>
            </el-col>
            <el-col>
              <p style="text-align:center">实时场内动态人数: {{ $store.state.aggregateDataInfo.ssnum || 0 }}人</p>
            </el-col>
            <el-col>
              <p style="text-align:right">平均停留时长: {{ $store.state.aggregateDataInfo.pjtime || 0+'分钟' }}</p>
            </el-col>
          </el-row>
        </div>
        <div style="background:#fff;padding:16px 5px 0 ;margin-bottom:32px;">
          <line-chart v-if=" $store.state.showlineChartDataAggregate" :chart-data=" $store.state.lineChartDataAggregate" />
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { getHourList, getDayList } from "@/api/activity";
import LineChart from "../../components/LineChart";

export default {
  components: { LineChart },
  data() {
    return {
      activeName: "0" // table栏默认激活项
    };
  },
  created() {
    this.$store.state.aggregateTime.startDate = null;
    getDayList({
      activityId: this.$store.state.thisActivityId,
      startDate: this.$store.state.aggregateTime.startDate
    });
  },
  methods: {
    async handleClick(tab) {
      // 切换table栏
      this.$store.state.aggregateTime.startDate = tab.label;
      // 切换table栏更新数据
      getHourList({
        activityId: this.$store.state.thisActivityId,
        startDate: this.$store.state.aggregateTime.startDate
      });
    }
  }
};
</script>

